#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 2e5 + 10;

int n, m;
long long arr[N];

int main()
{
    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> arr[i];
    sort(arr, arr + n);
    long long ret = 0;

    int index = n - m;
    if (index > 0)
    {
        ret += m * arr[index];
        for (int i = index + 1; i < n; i++) ret += arr[i] - arr[index];
    }
    else
    {
        for (int i = 0; i < n; i++) ret += arr[i];
    }

    cout << ret << endl;

    return 0;
}